import Vue from 'vue'
import Vuex from 'vuex'


Vue.use(Vuex);//vue的插件机制


//Vuex.Store 构造器选项
const store = new Vuex.Store({
	state:{//存放状态
		username:"请登入",
		backgroundImage:require('@/static/DogDongb.png'),
		avatarUrl:require('@/static/DogDongb.png'),
		token:"",
		//存放屏幕尺寸
		height:0
	},
	
	getters: {
		doneTodos: state => {
			return state.todos.filter(todo => todo.done)
		}
	},
	mutations: {
		adduser(state,userdata) {
			console.log(userdata)
			// 变更状态
			state.username = userdata.data.userName;
			state.avatarUrl = userdata.data.avatarUrl;
			state.backgroundImage = userdata.data.backgroundImage;
			state.token = userdata.data.token;
			uni.setStorageSync("token",state.token);	
		},
		uniscreenHeight(state,height){
			console.log("wx")
			console.log(height)
			state.height = height-50;
		}
	}
})
export default store